#include "observe.h"


Observe* Observe::Instance = nullptr;

void Observe::run_master()
{
    if(roleSwitch == ROLE_NONE){
        master.start();
        roleSwitch = ROLE_MASTER;
    }else if(roleSwitch == ROLE_SLAVE){
        slave.stop();
        master.start();
        roleSwitch = ROLE_MASTER;
    }   
}


void Observe::run_slave()
{
    if(roleSwitch == ROLE_NONE){
        slave.start();
        roleSwitch = ROLE_SLAVE;
    }else if(roleSwitch == ROLE_MASTER){
        master.stop();
        slave.start();
        roleSwitch = ROLE_SLAVE;
    }
}

